package com.ltkj.baseplatform.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ltkj.baseplatform.domain.bo.SerGameMemberBo;
import com.ltkj.baseplatform.domain.bo.SerGameMemberQueryBo;
import com.ltkj.baseplatform.domain.vo.SerGameMemberVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ltkj.common.log.annotation.Log;
import com.ltkj.common.log.enums.BusinessType;
import com.ltkj.common.security.annotation.RequiresPermissions;
import com.ltkj.baseplatform.domain.SerGameMember;
import com.ltkj.baseplatform.service.ISerGameMemberService;
import com.ltkj.common.core.web.controller.BaseController;
import com.ltkj.common.core.web.domain.AjaxResult;
import com.ltkj.common.core.utils.poi.ExcelUtil;
import com.ltkj.common.core.web.page.TableDataInfo;

/**
 * 赛事成员Controller
 * 
 * @author ruoyi
 * @date 2023-09-13
 */
@Api(tags = "赛事成员")
@RestController
@RequestMapping("/gamemember")
public class SerGameMemberController extends BaseController
{
    @Autowired
    private ISerGameMemberService serGameMemberService;

    /**
     * 查询赛事成员列表
     */
    @ApiOperation("查询赛事成员列表")
    @RequiresPermissions("baseplatform:gamemember:list")
    @GetMapping("/list")
    public TableDataInfo list(SerGameMemberQueryBo serGameMemberQueryBo)
    {
        startPage();
        List<SerGameMemberVo> list = serGameMemberService.selectSerGameMemberVoList(serGameMemberQueryBo);
        return getDataTable(list);
    }

    /**
     * 导出赛事成员列表
     */
    @ApiOperation("导出赛事成员列表")
    @RequiresPermissions("baseplatform:gamemember:export")
    @Log(title = "赛事成员", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SerGameMember serGameMember)
    {
        List<SerGameMember> list = serGameMemberService.selectSerGameMemberList(serGameMember);
        ExcelUtil<SerGameMember> util = new ExcelUtil<SerGameMember>(SerGameMember.class);
        util.exportExcel(response, list, "赛事成员数据");
    }

    /**
     * 获取赛事成员详细信息
     */
    @ApiOperation("获取赛事成员详细信息")
    @RequiresPermissions("baseplatform:gamemember:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(serGameMemberService.selectSerGameMemberVoById(id));
    }

    /**
     * 新增赛事成员
     */
    @ApiOperation("新增赛事成员")
    @RequiresPermissions("baseplatform:gamemember:add")
    @Log(title = "赛事成员", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Validated @RequestBody SerGameMemberBo serGameMember)
    {
        return toAjax(serGameMemberService.insertSerGameMember(serGameMember));
    }

    /**
     * 新增赛事成员
     */
    @ApiOperation("批量新增赛事成员")
    //@RequiresPermissions("baseplatform:gamemember:add")
    @Log(title = "赛事成员", businessType = BusinessType.INSERT)
    @PostMapping("addBatch")
    public AjaxResult addBatch(@RequestBody List<SerGameMemberBo> serGameMembers)
    {
        Long gameId = serGameMemberService.validateGameMember(serGameMembers);
        return toAjax(serGameMemberService.insertSerGameMemberBacth(serGameMembers,gameId));
    }

    /**
     * 修改赛事成员
     */
    @ApiOperation("修改赛事成员")
    @RequiresPermissions("baseplatform:gamemember:edit")
    @Log(title = "赛事成员", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody SerGameMemberBo serGameMember)
    {
        return toAjax(serGameMemberService.updateSerGameMember(serGameMember));
    }

    /**
     * 删除赛事成员
     */
    @ApiOperation("删除赛事成员")
    @RequiresPermissions("baseplatform:gamemember:remove")
    @Log(title = "赛事成员", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(serGameMemberService.deleteSerGameMemberByIds(ids));
    }
}
